import request from '@/utils/request'


import store from '@/store'

/**
 * 获取验证码
 * @param {*} data  手机号
 * @returns 
 */
export const captchaApi = (data) => {
  return request({
    url: '/GetCaptcha/sendCaptcha',
    method: 'POST',
    data,
    headers: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}
/**
 * 登录接口
 * @param {*} phone 
 * data = mobilephone: this.mobile,
          app_key: '1111',
          nonce: '11111',
          mobileMac: this.mobileMac,
          captcha: this.captcha.trim(),
          timestamp: new Date().toLocaleString()
 * @returns 
 */
export const loginApi = (data) => {
  return request({
    url: '/token/mobile',
    method: 'POST',
    data: {
      mobilephone: data.mobilephone,
      captcha: data.captcha,
      app_key: '1111',
      nonce: '11111',
      // mobileMac: this.mobileMac,
      timestamp: new Date().toLocaleString()
    }
  })
}
/**
 * 注册接口
 * @param {*} phone 
 * data = mobilephone: this.mobile,
     captcha: this.captcha,
     company: this.company,
     user: this.user,
     recommend: this.recommend,
     mobileMac: this.mobileMac //设备ID
 * @returns 
 */
export const registApi = (data) => {
  return request({
    url: '/Company/registUser',
    method: 'POST',
    data: {
      mobilephone: data.mobilephone,
      captcha: data.captcha,
      company: '某公司',
      user: '某领导',
      recommend: '',
      mobileMac: '' //设备ID
    }
  })
}



/**
 * 通知公告
 * @param {*} data 
 * @returns 
 */
export const notificationApi = (data) => {
  return request({
    url: '/company/getCompanyList',
    method: 'POST',
    data
  })
}

/**
 * 首页-操作频次 1、包含：登录用户、排刀计算、订单分享。
2、默认为：当天，
可以选择当月、当年。
 * @param {*} data 
 queryInfo = {
     timeB: timeB,
     timeE: timeE
}
 * @returns 
 */
export const handlerHzApi = (data) => {
  return request({
    url: '/company/getLogCount',
    method: 'POST',
    data
  })
}

/**
 * 参数配置 == 加工参数（获取）
 * @param {*} data 
 * data = {
     companyId: this.$store.state.user.userInfo.company_id
    }
 * @returns 
 */
export const paramsConfigApi = () => {
  return request({
    url: '/Company/getCompanyConfig',
    method: 'POST',
    data: {
      companyId: store.state.userInfo.company_id,
    }
  })
}

/**
 * 参数配置 == 加工参数（更新）
 * @param {*} data 
 * var data = {
      companyId: this.$store.state.user.userInfo.company_id,
      companyConfig: companyConfig,
      mobilephone: this.$store.state.user.userInfo.mobilephone
}
 * @returns 
 */
export const paramsConfigUpdateApi = (companyConfig) => {
  return request({
    url: '/Company/setCompanyConfig',
    method: 'POST',
    data: {
      companyId: store.state.userInfo.company_id,
      mobilephone: store.state.userInfo.mobilephone,
      companyConfig
    }
  })
}

/**
 * 组刀操作	存储原卷、成品信息
"var data = {
     material: material_info,
     produce: pro_info,
     companyConfig: companyConfig
}"

 * @param {*} data 
 * @returns 
 */
export const zdMessageApi = (data) => {
  return request({
    url: '/BisSteel/saveInfo',
    method: 'POST',
    data
  })
}

/**
 * 组刀操作	刀组清单
"var data = {
     material: material_info,
     produce: pro_info,
     companyConfig: companyConfig
    }
companyConfig，公司的配置信息"

 * @param {*} data 
 * @returns 
 */
export const inventoryApi = (data) => {
  return request({
    url: '/BisSteel/saveInfo',
    method: 'POST',
    data
  })
}

/**
 * 组刀操作	匹配计算、切换算法
"var data = {
     company_id: this.company_id,
     no: this.no,
     companyConfig:companyConfig,
     computeType: this.computeType
    }"

 * @param {*} data 
 * @returns 
 */
export const setCalculateApi = (data) => {
  return request({
    url: '/SizeMeet/SizeMeetSelect',
    method: 'POST',
    data,
    headers: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}
export const getCalculateApi = (data) => {
  return request({
    url: '/SizeMeet/getSizeMeet',
    method: 'POST',
    data,
    headers: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}
/**
 * 组刀操作	调整刀组重量
"var data = {
      company_id: this.company_id,
      no: this.no,
      materialSize: this.dialog.materialSize,
      oldWeight: this.old_weight,
      changeWeight: this.change_weight,
      sizeList: this.dialog.size_list,
      companyConfig: companyConfig
     }"

 * @param {*} data 
 * @returns 
 */
export const weightApi = (data) => {
  return request({
    url: '/SizeMeet/changeProc',
    method: 'POST',
    data
  })
}

/**
 * 组刀操作	取消
"var data = {
     company_id: this.company_id,
     no: this.no
}"

 * @param {*} data 
 * @returns 
 */
export const handleCancelApi = (data) => {
  return request({
    url: '/sys/login',
    method: 'POST',
    data
  })
}

/**
 * 组刀操作	获取加工报表（加工确定后，生成报表）
"var data = {
    company_id: this.company_id,
    no: this.no,
    weightCount: this.weightCount,
    weightRate: this.weightRate
}"

 * @param {*} data 
 * @returns 
 */
export const statementApi = (data) => {
  return request({
    url: '/SizeMeet/getReport',
    method: 'POST',
    data
  })
}

/**
 * 组刀操作	组刀记录
"var data = {
     companyId: this.$store.state.user.userInfo.company_id,
     pageS: pageS,
     pageE: pageE
    }"

 * @param {*} data 
 * @returns 
 */
export const zudaoRecordApi = (data) => {
  return request({
    url: '/SizeMeet/getOrderList',
    method: 'POST',
    data: {
      companyId: store.state.userInfo.company_id,
      pageS: data.pageS,
      pageE: data.pageE
    }
  })
}

/**
 * 个人中心	登录记录

 * "var data = {
     companyId: this.$store.state.user.userInfo.company_id,
     pageS: pageS,
     pageE: pageE
    }"

 * @param {*} data 
 * @returns 
 */
export const loginRecordApi = (data) => {
  return request({
    url: '/company/getLoginList',
    method: 'POST',
    data: {
      companyId: store.state.userInfo.company_id,
      pageS: data.pageS,
      pageE: data.pageE
    }
  })
}

